let arr = [1, 1, 1, 2, 2, 3, 3, { name: 'csc' }, { name: 'csc' }, 'a', 'b', 'a', true, false, true, Symbol('1'), Symbol('1'), 2n, 2n, [1], [1]]


// new Set()只能去重原始类型
// let res = Array.from(new Set(arr))

// console.log(res);

// indexOf,lastIndexOF
function quchon(arr) {
    let res = []
    for (let i = 0; i < arr.length; i++) {
        if (arr.indexOf(arr[i]) !== arr.lastIndexOf(arr[i])) {
            arr.splice(i, 1)
            i--
        }
        else {
            res.push(arr[i])
        }
    }
    return res
}

// map
function quchong1(arr) {
    const newArr = []
    arr.reduce((pre, next) => {
        if (!pre.has(next)) {
            pre.set(next, 1)
            newArr.push(next)
        }
        return pre
    }, new Map())
    return newArr
}

// console.log(res, quchong1(arr));

// includes
function quchon2(arr) {
    let res = []
    arr.forEach(item => {
        if(!res.includes(item)) {
            res.push(item)
        }
    })
    return res
}

console.log(quchon2(arr));
